import 'package:flutter/material.dart';
import 'package:flutter_book_store/home_model.dart';
import 'package:flutter_book_store/login/login.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:get/get.dart';

import 'book/book_model.dart';
import 'const.dart';
import 'routes/app_pages.dart';
import 'user/user_model.dart';

void main() {
  Get.lazyPut(() => UserModel());
  Get.lazyPut(() => BookModel());
  Get.put(HomeModel());
  runApp(LearnRootWidget());
}


class LearnRootWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    FlutterBoost.singleton.registerPageBuilders({
      'testPage': (pageName, params, _) {
        print("testPage params:$params");
        return LoginWidget();
      },
    });
    FlutterBoost.singleton
        .addBoostNavigatorObserver(TestBoostNavigatorObserver());

    return GetMaterialApp(
      theme: ThemeData(
          appBarTheme: AppBarTheme(
        elevation: 1,
        centerTitle: true,
        color: Colors.white,
        textTheme: TextTheme(
            title: TextStyle(
                fontSize: 20, color: black, fontWeight: FontWeight.bold)),
        iconTheme: IconThemeData(color: grey_text),
        actionsIconTheme: IconThemeData(color: Colors.blue),
      )),
      debugShowCheckedModeBanner: false,
      defaultTransition: Transition.fade,
      initialRoute: AppPages.INITIAL,
      getPages: AppPages.routes,
    );
  }
}

class TestBoostNavigatorObserver extends NavigatorObserver {
  void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
    print("flutterboost#didPush");
  }

  void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
    print("flutterboost#didPop");
  }

  void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
    print("flutterboost#didRemove");
  }

  void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
    print("flutterboost#didReplace");
  }
}
